include_directories(${PROJECT_SOURCE_DIR}/src ${OPENSSL_INCLUDE_DIR} ${LIBEVENT_INCLUDE_DIR}/include)

if (WIN32 OR CYGWIN)
	include_directories(${LIBEVENT_INCLUDE_DIR}/WIN32-Code)
endif (WIN32 OR CYGWIN)

set (BMTP_SRCS
	bmtp2.c
	bmtp2.h
	log.c
	log.h
	list.h
	stdafx2.h)
#	java/bmtp_bmtp_JBmtp.c
#	java/bmtp_bmtp_JBmtp.h)

if (UNIX)
#	set (BMTP_SRCS ${BMTP_SRCS}
#	os/linux/wbt_terminal.h)
    set (BMTP_LIBS ${BMTP_LIBS} event event_core event_extra event_pthreads)
    include_directories(/home/fcten/jdk1.8.0_111/include)
    include_directories(/home/fcten/jdk1.8.0_111/include/linux)
endif (UNIX)

if (WIN32 OR CYGWIN)
	set (BMTP_SRCS ${BMTP_SRCS}
	windows/dllmain.c)
endif (WIN32 OR CYGWIN)

set (BMTP_LIBS ${BMTP_LIBS} ${OPENSSL_LIBRARIES})

#if (UNIX)
#	if (APPLE)
#		set (BMTP_LIBS ${BMTP_LIBS} dl m)
#	else (APPLE)
#		set (BMTP_LIBS ${BMTP_LIBS} rt dl m)
#	endif (APPLE)
#endif (UNIX)

if (WIN32)
	set (BMTP_LIBS ${BMTP_LIBS} ${LIBEVENT_INCLUDE_DIR}/libevent.lib ${LIBEVENT_INCLUDE_DIR}/libevent_extras.lib ${LIBEVENT_INCLUDE_DIR}/libevent_core.lib)
	set (BMTP_LIBS ${BMTP_LIBS} ws2_32)
	add_definitions("-D_CRT_SECURE_NO_WARNINGS")
	add_definitions("-D_CRT_NONSTDC_NO_DEPRECATE")
endif (WIN32)

add_library(
    bmtp
    SHARED
    ${BMTP_SRCS}
)

add_library(
    bmtp_static
    STATIC
    ${BMTP_SRCS}
)

target_link_libraries(bmtp ${BMTP_LIBS})
target_link_libraries(bmtp_static ${BMTP_LIBS})

set_target_properties (bmtp_static PROPERTIES OUTPUT_NAME "bmtp")
set_target_properties (bmtp_static PROPERTIES CLEAN_DIRECT_OUTPUT 1)
set_target_properties (bmtp PROPERTIES CLEAN_DIRECT_OUTPUT 1)

set_target_properties (bmtp PROPERTIES	VERSION 0.5 SOVERSION 0.5)

install (TARGETS bmtp bmtp_static LIBRARY DESTINATION lib ARCHIVE DESTINATION lib)
install (FILES bmtp.h DESTINATION include/bmtp)

